from functools import lru_cache
from typing import Dict

from ygframe.util.import_util import get_all

from interface.resource import Resource

__author__ = 'jing'


@lru_cache()
def get_resource_mapper() -> Dict[str, type]:
    mapper = {}
    for cls in get_all('orm', Resource):
        if not issubclass(cls, Resource):
            continue
        mapper[cls.get_resource_type()] = cls
    return mapper
